package com.hnkywl.sts.action.kcgl;

import com.google.gson.Gson;
import com.hnkywl.sts.dao.kcgl.SskcDao;
import com.hnkywl.sts.entity.cggl.Cgd;
import com.hnkywl.sts.entity.sys.Gncz;
import com.hnkywl.sts.entity.xsgl.Kh;
import com.hnkywl.sts.service.cggl.CgdService;
import com.hnkywl.sts.service.kcgl.KcpdService;
import com.hnkywl.sts.service.kcgl.LldService;
import com.hnkywl.sts.service.kcgl.SskcService;
import com.hnkywl.sts.service.sys.GnczService;
import com.hnkywl.sts.service.xsgl.XsdService;
import com.hnkywl.sts.util.POIUtil;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.Region;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: lenovo
 * Date: 13-4-30
 * Time: 上午11:34
 * To change this template use File | Settings | File Templates.
 */
@Namespace("/kcgl/sskc")
public class SskcAction extends SimpleActionSupport {
    private SskcService sskcService;
    private CgdService cgdService;
    private XsdService xsdService;
    private LldService lldSerivce;
    private KcpdService kcpdService;
    private SskcDao sskcDao;
    //分页组件 起始位置
    private int page;
    //分页组件 页面大小
    private int rows;
    //行索引
    private int index;
    //查询条件
    private String ckmc;
    private String jtwzname;
    private String cgdh;
    private String khbm;
    private Long ckId;
    private Kh kh;
    private Long khId;
    private String rkdh;

    private Long gysId;
    private Cgd cgd;
    private String qk = "false";
    private String code;
    private String sbgsJc;
    private String cggsJc;
    private Date endDate = new Date();

    //功能操作
    private List<Gncz> gnczList;
    private GnczService gnczService;
    private String wzmc;
    private String khIds;
    private List<Kh> khList;
    private String gysName;
    private String ggxh;
    private String chtbm;
    private String xhtbm;
    private String qdrqstart;
    private String qdrqend;
    private String xsxt_xsdh;
    private String carno;
    private String bindno;
    private String fhrq;
    private String ckrqstart;
    private String ckrqend;
    private String sskczt;


    @Action("sskc")
    public String sskc() {
        gnczList = gnczService.findGnczByJsAndUrl(request.getServletPath());
        return SUCCESS;
    }

    //实时库存列表
    @Action("sskcList")
    public void sskcList() {
        this.renderJson(this.sskcService.findSskcList(chtbm, xhtbm, qdrqstart, qdrqend, xsxt_xsdh, carno, bindno, fhrq, ckrqstart, ckrqend, sskczt, page, rows));
    }

    //实时库存明细
    @Action("sskc_detail")
    public String sskcDetail() {
        if (khId != null) {
            kh = sskcService.findSskcDetail(khId);
        }
        return SUCCESS;
    }

    @Action("byif")
    public String buyerinfo() {
        gnczList = gnczService.findGnczByJsAndUrl(request.getServletPath());
        return SUCCESS;
    }

    //查询商户信息
    @Action("byifList")
    public void buyerinfoList() {
        this.renderJson(this.sskcService.findBuyerInfoList(code, wzmc, ggxh, gysName, page, rows));
    }

    @Action("byifChart")
    public void byifChart() throws ParseException {

        // 查询商户货权量
        List<Map> kcList = null;
        try {
            kcList = this.sskcService.findByifChart(java.net.URLDecoder.decode(code, "utf-8"), java.net.URLDecoder.decode(wzmc, "utf-8"), java.net.URLDecoder.decode(ggxh, "utf-8"), java.net.URLDecoder.decode(gysName, "utf-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }

        // x轴数据
        StringBuffer xsb = new StringBuffer();
        // y轴数据
        StringBuffer ysb = new StringBuffer();
        StringBuffer sbsl = new StringBuffer();
        StringBuffer rksl = new StringBuffer();
        StringBuffer wfpsl = new StringBuffer();
        xsb.append("[");
        sbsl.append("[");
        rksl.append("[");
        wfpsl.append("[");
        if (null != kcList && kcList.size() > 0) {
            for (int i = 0; i < kcList.size(); i++) {
                xsb.append("\"" + kcList.get(i).get("QC").toString() + "\"");
                sbsl.append(Double.valueOf((kcList.get(i).get("sbsl") == null ? 0d : kcList.get(i).get("sbsl")).toString()));
                rksl.append(Double.valueOf((kcList.get(i).get("rksl") == null ? 0d : kcList.get(i).get("rksl")).toString()));
                wfpsl.append(Double.valueOf((kcList.get(i).get("wfpsl") == null ? 0d : kcList.get(i).get("wfpsl")).toString()));
                if (i != kcList.size() - 1) {
                    xsb.append(",");
                    sbsl.append(",");
                    rksl.append(",");
                    wfpsl.append(",");
                }
            }
        }
        xsb.append("]");
        sbsl.append("]");
        rksl.append("]");
        wfpsl.append("]");
        this.renderJson("{ \"listXdata\":" + xsb + " , \"sbsl\":" + sbsl + " , \"rksl\":" + rksl + " , \"wfpsl\":" + wfpsl + "}");
    }

    //##################################挂单方法######################################

    //挂单跳转页面
    @Action("sskc_gdcontent")
    public String sskcGdContent() {
        return SUCCESS;
    }

    //挂单明细加载页面
    @Action("sskcGd_wzmx")
    public void sskcGdwzmx() {
        this.renderJson(this.sskcService.findWzMxFromKhIDs(khIds));
    }

    //挂单实际方法
    @Action("sskc_gd")
    public void sskcGd() {
        try {
            List<Map<String, Object>> map = sskcService.gd(khList);
            if (map == null || map.size() == 0) {
                renderText("{\"statusCode\":\"300\", \"message\":\"挂单失败\"}");
            } else {
                String Failures = "";
                for (int i = 0; i < map.size(); i++) {
                    if ("0".equals(map.get(i).get("code").toString())) {
                        sskcService.gdChangeKhKkdsl(map.get(i).get("resource_serial_number").toString());
                    } else {
                        Failures += sskcService.analyzeMapCgdh(map.get(i).get("resource_serial_number").toString());
                    }
                }
                if ("".equals(Failures)) {
                    Failures = "挂单成功";
                }
                renderText("{\"statusCode\":\"200\", \"message\":\"" + Failures + "\", \"operationType\":\"add\"}");
            }
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }


    //####################################################################################

    /**
     * 实时库存的导出
     *
     * @return
     */
    @Action("sskc_export")
    public String sskcExport() {
        SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
//        List<Map> sskcList = this.sskcDao.findKhList(sbgsJc, cggsJc, code, ckId, jtwzname, khbm, endDate, wzmc, qk);
        List<Map> sskclist = this.sskcDao.findSskcExpList(chtbm, xhtbm, qdrqstart, qdrqend, xsxt_xsdh, carno, bindno, fhrq, ckrqstart, ckrqend, sskczt);
        //第一步，创建一个webbook，对应一个Excel文件
        HSSFWorkbook wb = new HSSFWorkbook();
        //第二步，在webbook中添加一个sheet,对应Excel文件中的sheet
        HSSFSheet sheet = wb.createSheet("实时库存");
        POIUtil poiUtil = new POIUtil(wb);
        //设置列宽
        sheet.setDefaultRowHeightInPoints(15);
        sheet.setDefaultColumnWidth((short) 17);
        sheet.setColumnWidth((short) 0, (short) (11 * 512));
        sheet.setColumnWidth((short) 1, (short) (9 * 512));
        sheet.setColumnWidth((short) 2, (short) (9 * 512));
        sheet.setColumnWidth((short) 3, (short) (8 * 512));
        sheet.setColumnWidth((short) 4, (short) (6 * 512));
        sheet.setColumnWidth((short) 5, (short) (8 * 512));
        sheet.setColumnWidth((short) 6, (short) (6 * 512));
        sheet.setColumnWidth((short) 7, (short) (10 * 512));
        sheet.setColumnWidth((short) 8, (short) (6 * 512));
        sheet.setColumnWidth((short) 9, (short) (6 * 512));
        sheet.setColumnWidth((short) 10, (short) (6 * 512));
        sheet.setColumnWidth((short) 11, (short) (6 * 512));
        sheet.setColumnWidth((short) 12, (short) (6 * 512));
        sheet.setColumnWidth((short) 13, (short) (10 * 512));
        sheet.setColumnWidth((short) 14, (short) (6 * 512));
        sheet.setColumnWidth((short) 15, (short) (10 * 512));
        sheet.setColumnWidth((short) 16, (short) (10 * 512));
        sheet.setColumnWidth((short) 17, (short) (10 * 512));
        sheet.setColumnWidth((short) 18, (short) (10 * 512));
        sheet.setColumnWidth((short) 19, (short) (10 * 512));
        sheet.setColumnWidth((short) 20, (short) (6 * 512));
        sheet.setColumnWidth((short) 21, (short) (6 * 512));
        sheet.setColumnWidth((short) 22, (short) (6 * 512));
        //第三步，在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
        HSSFRow row = sheet.createRow((int) 0);
        row.setHeightInPoints(36);
        //第四步，创建单元格，并设置值表头  设置表头居中
        HSSFCellStyle titleStyle = poiUtil.createTitleHSSFCellStyle(wb);
        HSSFCell titleCell = row.createCell((short) 0);
        titleCell.setCellStyle(titleStyle);
        titleCell.setEncoding(HSSFCell.ENCODING_UTF_16);
        titleCell.setCellValue("实时库存导出汇总表");
        // 四个参数分别是：起始行，起始列，结束行，结束列
        sheet.addMergedRegion(new Region(0, (short) 0, 0, (short) 22));
        row = sheet.createRow((int) 1);
        row.setHeightInPoints(21);
        //生成第一行数据
        HSSFCell chtbm1 = row.createCell((short) 0);
        chtbm1.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        chtbm1.setEncoding(HSSFCell.ENCODING_UTF_16);
        chtbm1.setCellValue("采购合同号");

        HSSFCell xhtbm1 = row.createCell((short) 1);
        xhtbm1.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        xhtbm1.setEncoding(HSSFCell.ENCODING_UTF_16);
        xhtbm1.setCellValue("销售合同号");

        HSSFCell qdrq = row.createCell((short) 2);
        qdrq.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        qdrq.setEncoding(HSSFCell.ENCODING_UTF_16);
        qdrq.setCellValue("签订日期");

        HSSFCell xsdh = row.createCell((short) 3);
        xsdh.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        xsdh.setEncoding(HSSFCell.ENCODING_UTF_16);
        xsdh.setCellValue("销售合同子项号");

        HSSFCell carno1 = row.createCell((short) 4);
        carno1.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        carno1.setEncoding(HSSFCell.ENCODING_UTF_16);
        carno1.setCellValue("车皮号");

        HSSFCell bindno1 = row.createCell((short) 5);
        bindno1.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        bindno1.setEncoding(HSSFCell.ENCODING_UTF_16);
        bindno1.setCellValue("捆包号");

        HSSFCell fhrq1 = row.createCell((short) 6);
        fhrq1.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        fhrq1.setEncoding(HSSFCell.ENCODING_UTF_16);
        fhrq1.setCellValue("发货日期");

        HSSFCell name = row.createCell((short) 7);
        name.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        name.setEncoding(HSSFCell.ENCODING_UTF_16);
        name.setCellValue("品名");

        HSSFCell cz = row.createCell((short) 8);
        cz.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        cz.setEncoding(HSSFCell.ENCODING_UTF_16);
        cz.setCellValue("材质");

        HSSFCell ggxh = row.createCell((short) 9);
        ggxh.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        ggxh.setEncoding(HSSFCell.ENCODING_UTF_16);
        ggxh.setCellValue("规格型号");

        HSSFCell cd = row.createCell((short) 10);
        cd.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        cd.setEncoding(HSSFCell.ENCODING_UTF_16);
        cd.setCellValue("产地");

        HSSFCell dw = row.createCell((short) 11);
        dw.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        dw.setEncoding(HSSFCell.ENCODING_UTF_16);
        dw.setCellValue("单位");

        HSSFCell rkjs = row.createCell((short) 12);
        rkjs.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        rkjs.setEncoding(HSSFCell.ENCODING_UTF_16);
        rkjs.setCellValue("入库件数");

        HSSFCell rksl = row.createCell((short) 13);
        rksl.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        rksl.setEncoding(HSSFCell.ENCODING_UTF_16);
        rksl.setCellValue("入库重量");

        HSSFCell js = row.createCell((short) 14);
        js.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        js.setEncoding(HSSFCell.ENCODING_UTF_16);
        js.setCellValue("剩余件数");

        HSSFCell kkdsl = row.createCell((short) 15);
        kkdsl.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        kkdsl.setEncoding(HSSFCell.ENCODING_UTF_16);
        kkdsl.setCellValue("剩余重量");

        HSSFCell wsdj = row.createCell((short) 16);
        wsdj.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        wsdj.setEncoding(HSSFCell.ENCODING_UTF_16);
        wsdj.setCellValue("合同单价");

        HSSFCell sjdj = row.createCell((short) 17);
        sjdj.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        sjdj.setEncoding(HSSFCell.ENCODING_UTF_16);
        sjdj.setCellValue("实际单价");

        HSSFCell wsje = row.createCell((short) 18);
        wsje.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        wsje.setEncoding(HSSFCell.ENCODING_UTF_16);
        wsje.setCellValue("实际金额");

        HSSFCell ck = row.createCell((short) 19);
        ck.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        ck.setEncoding(HSSFCell.ENCODING_UTF_16);
        ck.setCellValue("仓库");
        HSSFCell rkrq = row.createCell((short) 20);
        rkrq.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        rkrq.setEncoding(HSSFCell.ENCODING_UTF_16);
        rkrq.setCellValue("入库日期");

        HSSFCell rkts = row.createCell((short) 21);
        rkts.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        rkts.setEncoding(HSSFCell.ENCODING_UTF_16);
        rkts.setCellValue("入库天数");

        HSSFCell ckrq = row.createCell((short) 22);
        ckrq.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        ckrq.setEncoding(HSSFCell.ENCODING_UTF_16);
        ckrq.setCellValue("出库日期");
        //表体部分
        for (int i = 2; i < sskclist.size() + 2; i++) {
            row = sheet.createRow(i);
            row.setHeightInPoints(19);

            chtbm1 = row.createCell((short) 0);
            chtbm1.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            chtbm1.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("chtbm")) {
                chtbm1.setCellValue(sskclist.get(i - 2).get("chtbm").toString());
            }

            xhtbm1 = row.createCell((short) 1);
            xhtbm1.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            xhtbm1.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("xhtbm")) {
                xhtbm1.setCellValue(sskclist.get(i - 2).get("xhtbm").toString());
            }

            qdrq = row.createCell((short) 2);
            qdrq.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            qdrq.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("qdrq")) {
                qdrq.setCellValue(sskclist.get(i - 2).get("qdrq").toString());
            }

            xsdh = row.createCell((short) 3);
            xsdh.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            xsdh.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("xsdh")) {
                xsdh.setCellValue(sskclist.get(i - 2).get("xsdh").toString());
            }

            carno1 = row.createCell((short) 4);
            carno1.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            carno1.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("carno")) {
                carno1.setCellValue(sskclist.get(i - 2).get("carno").toString());
            }

            bindno1 = row.createCell((short) 5);
            bindno1.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            bindno1.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("bindno")) {
                bindno1.setCellValue(sskclist.get(i - 2).get("bindno").toString());
            }

            fhrq1 = row.createCell((short) 6);
            fhrq1.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            fhrq1.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("fhrq")) {
                fhrq1.setCellValue(sskclist.get(i - 2).get("fhrq").toString());
            }

            name = row.createCell((short) 7);
            name.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            name.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("name")) {
                name.setCellValue(sskclist.get(i - 2).get("name").toString());
            }

            cz = row.createCell((short) 8);
            cz.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            cz.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("cz")) {
                cz.setCellValue(sskclist.get(i - 2).get("cz").toString());
            }

            ggxh = row.createCell((short) 9);
            ggxh.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            ggxh.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("ggxh")) {
                ggxh.setCellValue(sskclist.get(i - 2).get("ggxh").toString());
            }

            cd = row.createCell((short) 10);
            cd.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            cd.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("cd")) {
                cd.setCellValue(sskclist.get(i - 2).get("cd").toString());
            }

            dw = row.createCell((short) 11);
            dw.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            dw.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("dw")) {
                dw.setCellValue(sskclist.get(i - 2).get("dw").toString());
            }

            rkjs = row.createCell((short) 12);
            rkjs.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            rkjs.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("rkjs")) {
//                BigDecimal bigDecimal_rkjs = new BigDecimal(sskclist.get(i - 2).get("rkjs").toString()).setScale(3, BigDecimal.ROUND_HALF_UP);
//                rkjs.setCellValue(bigDecimal_rkjs.doubleValue());
                rkjs.setCellValue(sskclist.get(i - 2).get("rkjs").toString());
            }

            rksl = row.createCell((short) 13);
            rksl.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            rksl.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("rksl")) {
                BigDecimal bigDecimal_rksl = new BigDecimal(sskclist.get(i - 2).get("rksl").toString()).setScale(3, BigDecimal.ROUND_HALF_UP);
                rksl.setCellValue(bigDecimal_rksl.doubleValue());
            }

            js = row.createCell((short) 14);
            js.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            js.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("js")) {
                js.setCellValue(sskclist.get(i - 2).get("js").toString());
            }

            kkdsl = row.createCell((short) 15);
            kkdsl.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            kkdsl.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("kkdsl")) {
                BigDecimal bigDecimal_kkdsl = new BigDecimal(sskclist.get(i - 2).get("kkdsl").toString()).setScale(3, BigDecimal.ROUND_HALF_UP);
                kkdsl.setCellValue(bigDecimal_kkdsl.doubleValue());
            }

            wsdj = row.createCell((short) 16);
            wsdj.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            wsdj.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("wsdj")) {
                BigDecimal bigDecimal_wsdj = new BigDecimal(sskclist.get(i - 2).get("wsdj").toString()).setScale(3, BigDecimal.ROUND_HALF_UP);
                wsdj.setCellValue(bigDecimal_wsdj.doubleValue());
            }

            sjdj = row.createCell((short) 17);
            sjdj.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            sjdj.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("sjdj")) {
                BigDecimal bigDecimal_sjdj = new BigDecimal(sskclist.get(i - 2).get("sjdj").toString()).setScale(3, BigDecimal.ROUND_HALF_UP);
                sjdj.setCellValue(bigDecimal_sjdj.doubleValue());
            }

            wsje = row.createCell((short) 18);
            wsje.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            wsje.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("wsje")) {
                BigDecimal bigDecimal_wsje = new BigDecimal(sskclist.get(i - 2).get("wsje").toString()).setScale(3, BigDecimal.ROUND_HALF_UP);
                wsje.setCellValue(bigDecimal_wsje.doubleValue());
            }

            ck = row.createCell((short) 19);
            ck.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            ck.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("ck")) {
                ck.setCellValue(sskclist.get(i - 2).get("ck").toString());
            }

            rkrq = row.createCell((short) 20);
            rkrq.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            rkrq.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("rkrq")) {
                rkrq.setCellValue(sskclist.get(i - 2).get("rkrq").toString());
            }

            rkts = row.createCell((short) 21);
            rkts.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            rkts.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("rkts")) {
                rkts.setCellValue(sskclist.get(i - 2).get("rkts").toString());
            }

            ckrq = row.createCell((short) 22);
            ckrq.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            ckrq.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskclist.get(i - 2).get("ckrq")) {
                ckrq.setCellValue(sskclist.get(i - 2).get("ckrq").toString());
            }
        }

//        List<Map> sumList1 = sskcDao.findSumKh(null, sbgsJc, cggsJc, code, ckmc, gysId, ckId, jtwzname, cgdh, khbm, qk, endDate, wzmc);
        List<Map> sumList = sskcDao.findSumSskc(chtbm, xhtbm, qdrqstart, qdrqend, xsxt_xsdh, carno, bindno, fhrq, ckrqstart, ckrqend, sskczt);
        Double total_rkjs = 0d;//入库件数
        Double total_rksl = 0d;//入库数量
        Double total_js = 0d;//剩余件数
        Double total_kkdsl = 0d;//剩余重量
        Double total_wsje = 0d;//实际金额
        if (sumList.size() != 0) {
            for (Map map : sumList) {
                total_rkjs += Double.valueOf((map.get("rkjs") == null ? 0d : map.get("rkjs")).toString());
                total_rksl += Double.valueOf((map.get("rksl") == null ? 0d : map.get("rksl")).toString());
                total_js += Double.valueOf((map.get("js") == null ? 0d : map.get("js")).toString());
                total_kkdsl += Double.valueOf((map.get("kkdsl") == null ? 0d : map.get("kkdsl")).toString());
                total_wsje += Double.valueOf((map.get("sjje") == null ? 0d : map.get("sjje")).toString());
            }
        }
        BigDecimal bigDecimal_total_rkjs = new BigDecimal(total_rkjs).setScale(3, BigDecimal.ROUND_HALF_UP);
        BigDecimal bigDecimal_total_rksl = new BigDecimal(total_rksl).setScale(3, BigDecimal.ROUND_HALF_UP);
        BigDecimal bigDecimal_total_js = new BigDecimal(total_js).setScale(3, BigDecimal.ROUND_HALF_UP);
        BigDecimal bigDecimal_total_kkdsl = new BigDecimal(total_kkdsl).setScale(3, BigDecimal.ROUND_HALF_UP);
        BigDecimal bigDecimal_total_wsje = new BigDecimal(total_wsje).setScale(3, BigDecimal.ROUND_HALF_UP);

        //合计
        row = sheet.createRow(sskclist.size() + 2);
        row.setHeightInPoints(19);
        HSSFCell t0 = row.createCell((short) 0);
        t0.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        t0.setEncoding(HSSFCell.ENCODING_UTF_16);
        t0.setCellValue("");

        HSSFCell t1 = row.createCell((short) 1);
        t1.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        t1.setEncoding(HSSFCell.ENCODING_UTF_16);
        t1.setCellValue("合计：");

        HSSFCell t2 = row.createCell((short) 2);
        t2.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        t2.setEncoding(HSSFCell.ENCODING_UTF_16);
        t2.setCellValue("");

        HSSFCell t3 = row.createCell((short) 3);
        t3.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        t3.setEncoding(HSSFCell.ENCODING_UTF_16);
        t3.setCellValue("");

        HSSFCell t4 = row.createCell((short) 4);
        t4.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        t4.setEncoding(HSSFCell.ENCODING_UTF_16);
        t4.setCellValue("");

        HSSFCell h5 = row.createCell((short) 5);
        h5.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h5.setEncoding(HSSFCell.ENCODING_UTF_16);
        h5.setCellValue("");

        HSSFCell h6 = row.createCell((short) 6);
        h6.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h6.setEncoding(HSSFCell.ENCODING_UTF_16);
        h6.setCellValue("");

        HSSFCell h7 = row.createCell((short) 7);
        h7.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h7.setEncoding(HSSFCell.ENCODING_UTF_16);
        h7.setCellValue("");

        HSSFCell h8 = row.createCell((short) 8);
        h8.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h8.setEncoding(HSSFCell.ENCODING_UTF_16);
        h8.setCellValue("");

        HSSFCell h9 = row.createCell((short) 9);
        h9.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h9.setEncoding(HSSFCell.ENCODING_UTF_16);
        h9.setCellValue("");

        HSSFCell h10 = row.createCell((short) 10);
        h10.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h10.setEncoding(HSSFCell.ENCODING_UTF_16);
        h10.setCellValue("");

        HSSFCell h11 = row.createCell((short) 11);
        h11.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h11.setEncoding(HSSFCell.ENCODING_UTF_16);
        h11.setCellValue("");

        HSSFCell h12 = row.createCell((short) 12);
        h12.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h12.setEncoding(HSSFCell.ENCODING_UTF_16);
        h12.setCellValue(bigDecimal_total_rkjs.doubleValue());

        HSSFCell h13 = row.createCell((short) 13);
        h13.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h13.setEncoding(HSSFCell.ENCODING_UTF_16);
        h13.setCellValue(bigDecimal_total_rksl.doubleValue());

        HSSFCell h14 = row.createCell((short) 14);
        h14.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h14.setEncoding(HSSFCell.ENCODING_UTF_16);
        h14.setCellValue(bigDecimal_total_js.doubleValue());

        HSSFCell h15 = row.createCell((short) 15);
        h15.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h15.setEncoding(HSSFCell.ENCODING_UTF_16);
        h15.setCellValue(bigDecimal_total_kkdsl.doubleValue());

        HSSFCell h16 = row.createCell((short) 16);
        h16.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h16.setEncoding(HSSFCell.ENCODING_UTF_16);
        h16.setCellValue("");

        HSSFCell h17 = row.createCell((short) 17);
        h17.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h17.setEncoding(HSSFCell.ENCODING_UTF_16);
        h17.setCellValue("");

        HSSFCell h18 = row.createCell((short) 18);
        h18.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h18.setEncoding(HSSFCell.ENCODING_UTF_16);
        h18.setCellValue(bigDecimal_total_wsje.doubleValue());

        HSSFCell h19 = row.createCell((short) 19);
        h19.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h19.setEncoding(HSSFCell.ENCODING_UTF_16);
        h19.setCellValue("");

        HSSFCell h20 = row.createCell((short) 20);
        h20.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h20.setEncoding(HSSFCell.ENCODING_UTF_16);
        h20.setCellValue("");

        HSSFCell h21 = row.createCell((short) 21);
        h21.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h21.setEncoding(HSSFCell.ENCODING_UTF_16);
        h21.setCellValue("");

        HSSFCell h22 = row.createCell((short) 22);
        h22.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        h22.setEncoding(HSSFCell.ENCODING_UTF_16);
        h22.setCellValue("");

        try {
            response.setContentType("application/x-download");
            String filedisplay = new String(("实时库存汇总表.xls").getBytes("gb2312"), "iso8859-1");
            response.addHeader("Content-Disposition", "attachment;filename=" + filedisplay);
            OutputStream out = response.getOutputStream();
            wb.write(out);
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            renderText("位置异常，导出失败" + e.getMessage());
        }
        return null;
    }

    //采购单明细
    @Action("sskc_cgmx")
    public void sskcCgmx() {
        Gson gson = new Gson();
        List<Map> cgmx = this.cgdService.findCgmxByKh(kh);
        //入库件数
        Integer rkjs = 0;
        //入库数量
        Double rksl = 0d;
        //入库件重
        Double rkjz = 0d;
        String result = "";
        if (cgmx.size() > 0) {
            for (Map map : cgmx) {
                rkjs += map.get("rkjs") == null ? 0 : (Integer) map.get("rkjs");
                rkjz += map.get("rkjz") == null ? 0d : (Double) map.get("rkjz");
                rksl += map.get("rksl") == null ? 0d : (Double) map.get("rksl");
            }
            result = "{\"rows\":" + gson.toJson(cgmx) + ",\"footer\":[{\"cgd.cgdh\":\"采购合计:\",\"rkjs\":" + rkjs + ",\"rkjz\":" + rkjz + ",\"rksl\":" + rksl + " }]}";
        } else {
            result = "{\"rows\":" + gson.toJson(cgmx) + "}";
        }
        this.renderJson(result);
    }

    //销售单明细
    @Action("sskc_xsmx")
    public void sskcXsmx() {
        Gson gson = new Gson();
        //出库件数
        Integer ck_js = 0;
        //出库数量
        Double ck_sbsl = 0d;
        Double sbsl = 0d;
        String result = "";
        List<Map> xsmx = this.xsdService.findXsmxByKh(kh);
        if (xsmx.size() > 0) {
            for (Map map : xsmx) {
                sbsl += map.get("sbsl") == null ? 0d : (Double) map.get("sbsl");
                ck_js += map.get("ck_js") == null ? 0 : (Integer) map.get("ck_js");
                ck_sbsl += map.get("ck_sbsl") == null ? 0d : (Double) map.get("ck_sbsl");
            }
            result = "{\"rows\":" + gson.toJson(xsmx) + ",\"footer\":[{\"xsd.xsdh\":\"销售合计:\",\"sbsl\":" + sbsl + ",\"ck_js\":" + ck_js + ",\"ck_sbsl\":" + ck_sbsl + "}]}";
        } else {
            result = "{\"rows\":" + gson.toJson(xsmx) + "}";
        }
        this.renderJson(result);
    }

    //销售单明细
    @Action("sskc_lldmx")
    public void sskcLmx() {
        this.renderJson(this.lldSerivce.findLldmxDetailByKh(kh.getId()));
    }

    //库存盘点明细
    @Action("sskc_pdmx")
    public void sskcPdmx() {
        Gson gson = new Gson();
        List<Map> pdmx = this.kcpdService.findPdmxByKh(kh);
        String result = "{\"rows\":" + gson.toJson(pdmx) + "}";
        ;
        this.renderJson(result);
    }


    @Action("qk")
    public void qk() {
        try {
            sskcService.changeStatus(khId, qk);
            renderText("{\"statusCode\":\"200\", \"message\":\"清卡成功！\", \"operationType\":\"check\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }

    }

    @Action("qx_qk")
    public void qx() {
        try {
            sskcService.changeStatus(khId, qk);
            renderText("{\"statusCode\":\"200\", \"message\":\"取消成功！\", \"operationType\":\"check\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }

    }

    /**
     * 库存成本调整
     */
    @Action("kccbtz")
    public void kccbtz() {
        try {
            sskcService.kccbtz(kh);
            renderText("{\"statusCode\":\"200\", \"message\":\"保存成功\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }

    @Action("sskc_pkExport")
    public String sskcPkExport() {
        SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
        List<Map> sskcList = this.sskcDao.findPkList(ckId);
        //第一步，创建一个webbook，对应一个Excel文件
        HSSFWorkbook wb = new HSSFWorkbook();
        //第二步，在webbook中添加一个sheet,对应Excel文件中的sheet
        HSSFSheet sheet = wb.createSheet("月度库存盘点");
        POIUtil poiUtil = new POIUtil(wb);
        //设置列宽
        sheet.setDefaultRowHeightInPoints(15);
        sheet.setDefaultColumnWidth((short) 12);
        sheet.setColumnWidth((short) 0, (short) (11 * 512));
        sheet.setColumnWidth((short) 1, (short) (9 * 512));
        sheet.setColumnWidth((short) 2, (short) (9 * 512));
        sheet.setColumnWidth((short) 3, (short) (15 * 512));
        sheet.setColumnWidth((short) 4, (short) (15 * 512));
        sheet.setColumnWidth((short) 5, (short) (6 * 512));
        sheet.setColumnWidth((short) 6, (short) (6 * 512));
        sheet.setColumnWidth((short) 7, (short) (10 * 512));
        sheet.setColumnWidth((short) 8, (short) (6 * 512));
        sheet.setColumnWidth((short) 9, (short) (6 * 512));
        sheet.setColumnWidth((short) 10, (short) (6 * 512));
        sheet.setColumnWidth((short) 11, (short) (10 * 512));
        sheet.setColumnWidth((short) 12, (short) (10 * 512));
        //第三步，在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
        HSSFRow row = sheet.createRow((int) 0);
        row.setHeightInPoints(36);
        //第四步，创建单元格，并设置值表头  设置表头居中
        HSSFCellStyle titleStyle = poiUtil.createTitleHSSFCellStyle(wb);
        HSSFCell titleCell = row.createCell((short) 0);
        titleCell.setCellStyle(titleStyle);
        titleCell.setEncoding(HSSFCell.ENCODING_UTF_16);
        titleCell.setCellValue("月度库存盘点导出汇总表");
        // 四个参数分别是：起始行，起始列，结束行，结束列
        sheet.addMergedRegion(new Region(0, (short) 0, 0, (short) 16));
        row = sheet.createRow((int) 1);
        row.setHeightInPoints(21);
        //生成第一行数据
        HSSFCell khbm = row.createCell((short) 0);
        khbm.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        khbm.setEncoding(HSSFCell.ENCODING_UTF_16);
        khbm.setCellValue("卡号");

        HSSFCell oldcode = row.createCell((short) 1);
        oldcode.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        oldcode.setEncoding(HSSFCell.ENCODING_UTF_16);
        oldcode.setCellValue("老物资编码");

        HSSFCell code = row.createCell((short) 2);
        code.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        code.setEncoding(HSSFCell.ENCODING_UTF_16);
        code.setCellValue("新物资编码");

        HSSFCell wzname = row.createCell((short) 3);
        wzname.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        wzname.setEncoding(HSSFCell.ENCODING_UTF_16);
        wzname.setCellValue("物资名称");

        HSSFCell ggxh = row.createCell((short) 4);
        ggxh.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        ggxh.setEncoding(HSSFCell.ENCODING_UTF_16);
        ggxh.setCellValue("规格型号");

        HSSFCell th = row.createCell((short) 5);
        th.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        th.setEncoding(HSSFCell.ENCODING_UTF_16);
        th.setCellValue("图号");

        HSSFCell cz = row.createCell((short) 6);
        cz.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        cz.setEncoding(HSSFCell.ENCODING_UTF_16);
        cz.setCellValue("材质");

        HSSFCell dw = row.createCell((short) 7);
        dw.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        dw.setEncoding(HSSFCell.ENCODING_UTF_16);
        dw.setCellValue("单位");

        HSSFCell ck = row.createCell((short) 8);
        ck.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        ck.setEncoding(HSSFCell.ENCODING_UTF_16);
        ck.setCellValue("仓库");

        HSSFCell byrk = row.createCell((short) 9);
        byrk.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        byrk.setEncoding(HSSFCell.ENCODING_UTF_16);
        byrk.setCellValue("本月入库");

        HSSFCell byck = row.createCell((short) 10);
        byck.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        byck.setEncoding(HSSFCell.ENCODING_UTF_16);
        byck.setCellValue("本月出库");

        HSSFCell sykc = row.createCell((short) 11);
        sykc.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        sykc.setEncoding(HSSFCell.ENCODING_UTF_16);
        sykc.setCellValue("本月库存");

        HSSFCell bykc = row.createCell((short) 12);
        bykc.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        bykc.setEncoding(HSSFCell.ENCODING_UTF_16);
        bykc.setCellValue("上月库存");
        //表体部分
        for (int i = 2; i < sskcList.size() + 2; i++) {
            row = sheet.createRow(i);
            row.setHeightInPoints(19);

            khbm = row.createCell((short) 0);
            khbm.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            khbm.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskcList.get(i - 2).get("KHBM")) {
                khbm.setCellValue(sskcList.get(i - 2).get("KHBM").toString());
            }

            oldcode = row.createCell((short) 1);
            oldcode.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            oldcode.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskcList.get(i - 2).get("OLDCODE")) {
                oldcode.setCellValue(sskcList.get(i - 2).get("OLDCODE").toString());
            }

            code = row.createCell((short) 2);
            code.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            code.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskcList.get(i - 2).get("CODE")) {
                code.setCellValue(sskcList.get(i - 2).get("CODE").toString());
            }

            wzname = row.createCell((short) 3);
            wzname.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            wzname.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskcList.get(i - 2).get("NAME")) {
                wzname.setCellValue(sskcList.get(i - 2).get("NAME").toString());
            }

            ggxh = row.createCell((short) 4);
            ggxh.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            ggxh.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskcList.get(i - 2).get("GGXH")) {
                ggxh.setCellValue(sskcList.get(i - 2).get("GGXH").toString());
            }

            th = row.createCell((short) 5);
            th.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            th.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskcList.get(i - 2).get("TH")) {
                th.setCellValue(sskcList.get(i - 2).get("TH").toString());
            }

            cz = row.createCell((short) 6);
            cz.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            cz.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskcList.get(i - 2).get("CZ")) {
                cz.setCellValue(sskcList.get(i - 2).get("CZ").toString());
            }

            dw = row.createCell((short) 7);
            dw.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            dw.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskcList.get(i - 2).get("DW")) {
                dw.setCellValue(sskcList.get(i - 2).get("DW").toString());
            }

            ck = row.createCell((short) 8);
            ck.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            ck.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskcList.get(i - 2).get("MC")) {
                ck.setCellValue(sskcList.get(i - 2).get("MC").toString());
            }

            byrk = row.createCell((short) 9);
            byrk.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            byrk.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskcList.get(i - 2).get("BYRK")) {
                BigDecimal bigDecimal_byrk = new BigDecimal(sskcList.get(i - 2).get("BYRK").toString()).setScale(3, BigDecimal.ROUND_HALF_UP);
                byrk.setCellValue(bigDecimal_byrk.doubleValue());
            }

            byck = row.createCell((short) 10);
            byck.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            byck.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskcList.get(i - 2).get("BYCK")) {
                BigDecimal bigDecimal_byck = new BigDecimal(sskcList.get(i - 2).get("BYCK").toString()).setScale(3, BigDecimal.ROUND_HALF_UP);
                byck.setCellValue(bigDecimal_byck.doubleValue());
            }

            bykc = row.createCell((short) 11);
            bykc.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            bykc.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskcList.get(i - 2).get("BYKC")) {
                BigDecimal bigDecimal_bykc = new BigDecimal(sskcList.get(i - 2).get("BYKC").toString()).setScale(3, BigDecimal.ROUND_HALF_UP);
                bykc.setCellValue(bigDecimal_bykc.doubleValue());
            }

            sykc = row.createCell((short) 12);
            sykc.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            sykc.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != sskcList.get(i - 2).get("SYKC")) {
                BigDecimal bigDecimal_sykc = new BigDecimal(sskcList.get(i - 2).get("SYKC").toString()).setScale(3, BigDecimal.ROUND_HALF_UP);
                sykc.setCellValue(bigDecimal_sykc.doubleValue());
            }
        }

        try {
            response.setContentType("application/x-download");
            String filedisplay = new String(("月度库存盘点汇总表.xls").getBytes("gb2312"), "iso8859-1");
            response.addHeader("Content-Disposition", "attachment;filename=" + filedisplay);
            wb.write(response.getOutputStream());
            response.getOutputStream().close();
        } catch (Exception e) {
            e.printStackTrace();
            renderText("位置异常，导出失败" + e.getMessage());
        }
        return null;
    }

    // 加工单查询库存
    @Action("jgdKcList")
    public void jgdKcList() {
        this.renderJson(this.sskcService.findjgdSskcList(sbgsJc, cggsJc, code, ckmc, gysId, ckId, jtwzname, cgdh, khbm, qk, wzmc, rkdh, page, rows));
    }
    //=========getter===setter====================

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public String getCkmc() {
        return ckmc;
    }

    public void setCkmc(String ckmc) {
        this.ckmc = ckmc;
    }

    public String getJtwzname() {
        return jtwzname;
    }

    public void setJtwzname(String jtwzname) {
        this.jtwzname = jtwzname;
    }

    public String getCgdh() {
        return cgdh;
    }

    public void setCgdh(String cgdh) {
        this.cgdh = cgdh;
    }

    public String getKhbm() {
        return khbm;
    }

    public void setKhbm(String khbm) {
        this.khbm = khbm;
    }

    public Long getCkId() {
        return ckId;
    }

    public void setCkId(Long ckId) {
        this.ckId = ckId;
    }

    public Kh getKh() {
        return kh;
    }

    public void setKh(Kh kh) {
        this.kh = kh;
    }

    public Long getKhId() {
        return khId;
    }

    public void setKhId(Long khId) {
        this.khId = khId;
    }

    public Long getGysId() {
        return gysId;
    }

    public List<Kh> getKhList() {
        return khList;
    }

    public void setKhList(List<Kh> khList) {
        this.khList = khList;
    }

    public void setGysId(Long gysId) {
        this.gysId = gysId;
    }

    public Cgd getCgd() {
        return cgd;
    }

    public void setCgd(Cgd cgd) {
        this.cgd = cgd;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getQk() {
        return qk;
    }

    public void setQk(String qk) {
        this.qk = qk;
    }

    public List<Gncz> getGnczList() {
        return gnczList;
    }

    public void setGnczList(List<Gncz> gnczList) {
        this.gnczList = gnczList;
    }

    public String getSbgsJc() {
        return sbgsJc;
    }

    public void setSbgsJc(String sbgsJc) {
        this.sbgsJc = sbgsJc;
    }

    public String getCggsJc() {
        return cggsJc;
    }

    public void setCggsJc(String cggsJc) {
        this.cggsJc = cggsJc;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public String getWzmc() {
        return wzmc;
    }

    public void setWzmc(String wzmc) {
        this.wzmc = wzmc;
    }

    public String getKhIds() {
        return khIds;
    }

    public void setKhIds(String khIds) {
        this.khIds = khIds;
    }

    public SskcService getSskcService() {
        return sskcService;
    }

    public String getRkdh() {
        return rkdh;
    }

    public void setRkdh(String rkdh) {
        this.rkdh = rkdh;
    }

    public String getGysName() {
        return gysName;
    }

    public void setGysName(String gysName) {
        this.gysName = gysName;
    }

    public String getGgxh() {
        return ggxh;
    }

    public void setGgxh(String ggxh) {
        this.ggxh = ggxh;
    }

    public String getXsxt_xsdh() {
        return xsxt_xsdh;
    }

    public void setXsxt_xsdh(String xsxt_xsdh) {
        this.xsxt_xsdh = xsxt_xsdh;
    }

    public String getChtbm() {
        return chtbm;
    }

    public void setChtbm(String chtbm) {
        this.chtbm = chtbm;
    }

    public String getXhtbm() {
        return xhtbm;
    }

    public void setXhtbm(String xhtbm) {
        this.xhtbm = xhtbm;
    }

    public String getQdrqstart() {
        return qdrqstart;
    }

    public void setQdrqstart(String qdrqstart) {
        this.qdrqstart = qdrqstart;
    }

    public String getQdrqend() {
        return qdrqend;
    }

    public void setQdrqend(String qdrqend) {
        this.qdrqend = qdrqend;
    }

    public void setCkrqstart(String ckrqstart) {
        this.ckrqstart = ckrqstart;
    }

    public void setCkrqend(String ckrqend) {
        this.ckrqend = ckrqend;
    }

    public String getCarno() {
        return carno;
    }

    public void setCarno(String carno) {
        this.carno = carno;
    }

    public String getBindno() {
        return bindno;
    }

    public void setBindno(String bindno) {
        this.bindno = bindno;
    }

    public String getFhrq() {
        return fhrq;
    }

    public void setFhrq(String fhrq) {
        this.fhrq = fhrq;
    }

    public String getCkrqstart() {
        return ckrqstart;
    }

    public String getCkrqend() {
        return ckrqend;
    }

    public String getSskczt() {
        return sskczt;
    }

    public void setSskczt(String sskczt) {
        this.sskczt = sskczt;
    }

    @Autowired
    public void setGnczService(GnczService gnczService) {
        this.gnczService = gnczService;
    }

    @Autowired
    public void setSskcService(SskcService sskcService) {
        this.sskcService = sskcService;
    }

    @Autowired
    public void setCgdService(CgdService cgdService) {
        this.cgdService = cgdService;
    }

    @Autowired
    public void setXsdService(XsdService xsdService) {
        this.xsdService = xsdService;
    }

    @Autowired
    public void setLldSerivce(LldService lldSerivce) {
        this.lldSerivce = lldSerivce;
    }

    @Autowired
    public void setKcpdService(KcpdService kcpdService) {
        this.kcpdService = kcpdService;
    }

    @Autowired
    public void setSskcDao(SskcDao sskcDao) {
        this.sskcDao = sskcDao;
    }
}
